#!/bin/bash

dir="$(pwd)"
bin="$0"
while [ -L "${bin}" ]
do
	x="$(readlink "${bin}")"
	cd "$(dirname "${bin}")"
	bin="${x}"
done
cd "$(dirname "${bin}")" || exit 1
home="$(pwd)"
cd "${dir}"

#dir="`pwd`"
#cd "$(dirname "$0")"
#home="`pwd`"
#cd "${dir}"

echopath () {
  if [ -d "$1" ]; then
    echo "$1"
  fi
}

echopath "${home}"

#if [ "${home}" != "${HOME}/bin" ]; then
  #echopath "${HOME}/bin"
#fi

